package sg.nus.iss.vmcs.gui.elements;

import java.awt.Panel;
import java.awt.event.ActionListener;

import sg.nus.iss.vmcs.models.StoreItemObserver;

/**
 * The store viewer item, a base class for user controls displaying Store Items
 * Currently used by ButtonItem, LabelledDisplay and DrinkSelectionItem
 * @author Philip Chew
 */
public abstract class StoreViewerItem extends Panel implements VariableDisplayStateContext, StoreItemObserver {

	/** Generated Serial ID */
	private static final long serialVersionUID = -5746920900052359285L;
	
	/** Index for occasions when the StoreViewerItem is part of a list */
	private int index = -1;
	
	/** VariableDisplayState used for the Store Viewer */
	protected VariableDisplayState vds;
	
	/**
	 * Creates a new instance of the Store Viewer Item
	 * @param ids
	 */
	public StoreViewerItem(ItemDisplayStrategy ids){}
	
	/**
	 * Sets the name of the Store Viewer Item
	 * @param name Name to set
	 */
	public abstract void setName(String name);
	
	/**
	 * Sets the Quantity to be displayed
	 * @param qty Quantity to set
	 */
	public abstract void setQuantity(int qty);
	
	/**
	 * Sets the value of the StoreViewerItem 
	 * @param value Integer value to set
	 */
	public void setValue(int value) {
		setValue(String.valueOf(value));
	}
	
	/**
	 * Sets the value of the StoreViewerItem 
	 * @param value String value to set
	 */
	public abstract void setValue(String value);
	
	/**
	 * Adds a listener to the StoreViewerItem
	 * @param al ActionListener to set
	 */
	public abstract void addListener(ActionListener listener);
	
	/**
	 * Sets the action command of the StoreViewerItem if required
	 * @param cmd ActionCommand to set
	 */
	public abstract void setActionCommand(String command);
	
	/** 
	 * Sets the active or inactive state of a StoreViewerItem
	 */
	public abstract void setActive(boolean active);
	
	/**
	 * Sets the index of a StoreViewerItem
	 */
	public void setIndex(int index) {
		this.index = index;
	}
	
	/**
	 * Gets the index of a StoreViewerItem
	 */
	public int getIndex() {
		return index;
	}
	
	/* 
	 * Sets the Variable Display State
	 */
	@Override
	public void setVariableDisplayState(VariableDisplayState vds) {
		this.vds = vds;
	}
}
